<script setup>
import { ref, watch } from "vue";
import { useMyToastStore } from "@/store/myToast";
const myToast = useMyToastStore();
let toast = ref(null);
// success,error,warning
watch(
  () => myToast.params,
  (newValue) => {
    if (newValue.message) {
      toast.value.show({
        ...myToast.params,
        duration: 1500,
        complete: () => {
          if (typeof newValue.complete === "function") {
            newValue.complete();
          }
          myToast.$reset();
        },
      });
    }
  }
);
</script>

<template>
  <view class="my-toast">
    <u-toast ref="toast"></u-toast>
  </view>
</template>
